/*
 * ArticleCommentActivity.java
 * business
 *
 * Created by chentao on 2017/4/21.
 *
 * Copyright (c) 2017年 yidiandao. All rights reserved.
 */

package com.yidiandao.business.ui.main.discovery.comment;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;

import com.yidiandao.business.R;
import com.yidiandao.business.base.BaseActivity;
import com.yidiandao.business.constant.Intents;
import com.yidiandao.business.data.model.ArticleModel;
import com.yidiandao.business.utils.ActivityUtils;

/**
 * 发现-评论-Activity.
 */
public class ArticleCommentActivity extends BaseActivity {

    private ArticleCommentFragment mCommentFragment;

    public static void actionStart(Activity activity, String articleId, boolean commentNow) {
        Intent intent = new Intent(activity, ArticleCommentActivity.class);
        intent.putExtra(Intents.ARTICLE_ID, articleId);
        intent.putExtra(Intents.SHOW_COMMENT_DIALOG, commentNow);
        activity.startActivity(intent);
    }

    @Override
    protected void initFragment() {
        mCommentFragment = (ArticleCommentFragment) getSupportFragmentManager().findFragmentById(R.id.container_discovery_comment);

        if (mCommentFragment == null) {
            mCommentFragment = ArticleCommentFragment.getInstance();
            ActivityUtils.addFragmentToActivity(getSupportFragmentManager(), mCommentFragment, R.id.container_discovery_comment);
        }

    }

    @Override
    protected void initPresenter() {
        Bundle bundle = getIntent().getExtras();
        String articleId = bundle.getString(Intents.ARTICLE_ID);
        boolean showCommentDialog = bundle.getBoolean(Intents.SHOW_COMMENT_DIALOG);
        new ArticleCommentPresenter(mCommentFragment, articleId, new ArticleModel());
    }

    @Override
    protected int getLayoutId() {
        return R.layout.activity_article_comment;
    }
}
